//
//  HXRuntimeStatus.m
//  ChatDemo-UI2.0
//
//  Created by romens on 15/6/17.
//  Copyright (c) 2015年 romens. All rights reserved.
//

#import "HXRuntimeStatus.h"
#import "HXDDUserEntity.h"
#import <MJExtension/NSObject+MJKeyValue.h>
@implementation HXRuntimeStatus

+ (instancetype)instance
{
    static HXRuntimeStatus* g_runtimeState;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        g_runtimeState = [[HXRuntimeStatus alloc] init];
        
    });
    NSDictionary*dic=GetUserDefaults(@"userinfo");
    if(dic)
    {
        g_runtimeState.user=[HXDDUserEntity mj_objectWithKeyValues:dic];
    }
    return g_runtimeState;
}
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.ALLUsers=[NSMutableArray new];
        self.ERPstores = [[NSMutableArray alloc] init];
    }
    return self;
}

-(HXDDUserEntity *)GetUserForName:(NSString*)phone
{
    for (HXDDUserEntity *user in self.ALLUsers) {
        if([user.name isEqualToString:phone])
        {
            return user;
        }
    }
    return  nil;
}
#pragma mark--遍历ERP的相关数据
- (ERPstore *)GetERPInfoForFACADE:(NSString *)FACADE {
    for (ERPstore *store in self.ERPstores) {
        if ([store.FACADE isEqualToString:FACADE]) {
            return store;
        }
    }
    return nil;
}

@end
